package cn.ilikes.tools.nosql.jpa.clients.schemas;

import org.slf4j.Logger;

import cn.ilikes.tools.logs.Loggerfactory;
import cn.ilikes.tools.nosql.jpa.JPASQLPersistenUnitEnv;
import cn.ilikes.tools.nosql.jpa.SysConfigs;
import cn.ilikes.tools.nosql.jpa.clients.schemas.ISchemaManager.DialectType;

public class DefultSchemaManagerFactory implements ISchemaManagerFactory {

	private Logger logger = Loggerfactory.instance(DefultSchemaManagerFactory.class);

	private JPASQLPersistenUnitEnv persistenUnitEnv;

	public DefultSchemaManagerFactory(JPASQLPersistenUnitEnv persistenUnitEnv) {
		super();
		this.persistenUnitEnv = persistenUnitEnv;
	}

	@Override
	public void createSchema() {
		Loggerfactory.info(logger, "Schema Manager Factory Start  create " + persistenUnitEnv.getPersistenUnitName() + " ' Schema  ");
		String dialect = ((String) persistenUnitEnv.getPersistenceUnitMetadata().getProperties().get(SysConfigs.jpa_dialect)).toUpperCase();
		DialectType dialectType = DialectType.valueOf(dialect);
		switch (dialectType) {
		case HBASE: {
			HBaseSchemaManager.createSchema(persistenUnitEnv);
		}
			break;
		case MYSQL:

			break;

		default:
			throw new JPASQLchemaRuntimeException("not find dialect type " + dialectType + " 's  type !  ");

		}

	}

}
